<?php
/**
 * Created by PhpStorm.
 * User: david
 * Date: 5/11/19
 * Time: 8:58 PM
 */

namespace App\Transformers;


use App\Models\Role;
use App\Models\UserRole;
use League\Fractal\TransformerAbstract;

class UserRoleTransformer extends TransformerAbstract
{
    public function transform(UserRole $userRole)
    {
        return [
            'id' => $userRole->id,
            'user_id' => $userRole->user_id,
            'role_id' => $userRole->role_id,
            'role' => Role::ROLES[(string) $userRole->role_id] ?? '',
        ];
    }
}